<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>申请试用</title>
		<link rel="stylesheet" href="/Public/css/style.css" />
		<link rel="stylesheet" href="/Public/css/general.css" />
	</head>
	<body>
		<div class="message">
			<p class="try-tit">申请试用</p>
			<table style="border-collapse:separate; border-spacing:20px;">
				<tr>
					<th><span style="color: red;margin-right: 5px;">*</span>姓名</th>
					<td class="inneed"><input type="text" placeholder="请输入真实姓名" name="name"></td>
				</tr>
				<tr>
					<th><span style="color: red;margin-right: 5px;">*</span>电话</th>
					<td class="inneed"><input type="text" placeholder="请输入手机号" name="tel"></td>
				</tr>
				<tr>
					<th>其它联系方式</th>
					<td><input type="text" placeholder="请输入QQ号，邮箱号" name="otherway"></td>
				</tr>
				<tr>
					<th><span style="color: red;margin-right: 5px;">*</span>留言内容</th>
					<td><textarea name="" id="mes" placeholder="请输入不少于10个字的留言内容"></textarea></td>
				</tr>
				<tfoot>
					<th></th>
					<td>
						<a class="tj">提交申请</a>
					</td>
				</tfoot>
			</table>
		</div>	
		<script src="/Public/js/jquery-2.1.1.min.js" ></script>
		<script src="/Public/layer/layer.js"></script>
		<script>
			$(".tj").click(function() {
				var date = new Date();
			    var seperator1 = "-";
			    var seperator2 = ":";
			    var month = date.getMonth() + 1;
			    var strDate = date.getDate();
			    if (month >= 1 && month <= 9) {
			        month = "0" + month;
			    }
			    if (strDate >= 0 && strDate <= 9) {
			        strDate = "0" + strDate;
			    }
			    var time = date.getFullYear() + seperator1 + month + seperator1 + strDate
			            + " " + date.getHours() + seperator2 + date.getMinutes()
			            + seperator2 + date.getSeconds();
				var name = $("input[name=name]").val(),
				 	tel = $("input[name=tel]").val(),
					otherway = $("input[name=otherway]").val(),
					mes=$("#mes").val();
				
			if(!name){
				layer.alert("请输入姓名" ,{time:2300});return false;
			}
			if(!tel){
				layer.alert("请输入手机号码",{time:2300});return false;
			}
			if(!mes){
				layer.alert("留言不能为空",{time:2300});return false;
			}
			if(!(/^1(3|4|5|7|8)\d{9}$/.test(tel))){ 
            	layer.alert("手机号码有误，请重填",{time:3000});return false;
        	} 
			if((name && tel && mes)){
				$.ajax({
					type: "post",
					url: "<?php echo U('admin/index/ajax');?>",
					data: {name: name,tel: tel,otherway: otherway, mes:mes,time:time},
					dataType: "json",
					success: function (data) {
						if(data.status == 1){
							layer.alert("提交成功！请等待审核",{time:3000});
							$("input[name=tel]").val('');
							$("input[name=name]").val('');
							$("input[name=otherway]").val('');
							$("#mes").val('');
							
						}
					}
				});
			}else{
				alert('请填写完整的信息');
			}
		});
		</script>
	</body>
</html>